﻿#region
/*******************************************************************************
** File Name:		    MemberInfoService.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using EWineShop.Service.Contracts;
using EWineShop.Service.Model;
using EWineShop.IBatisRepository;
using EWineShop.Respository;
using System.Data;
using EWineShop.Entity;

namespace EWineShop.Service
{
    public class MemberInfoService : IMemberInfoService
    {
		 IMemberInfo memberInfo = new MemberInfoRepository();
		 
		 #region  Auto Generation
		 

	
		public IList<MemberInfoModel> GetAll ()
		{
			IList<EMemberInfo> entity = memberInfo.GetAll();
			
			if (entity == null)
            {
                return null;
            }
            
            IList<MemberInfoModel> list = new List<MemberInfoModel>();

            foreach (var item in entity)
            {
                MemberInfoModel model = ConvertEntityToModel(item);
                list.Add(model);
            }
            return list;   
			
		}
		
		private MemberInfoModel ConvertEntityToModel(EMemberInfo entity)
		{
			if (entity == null)
            {
                return null;
            }
			MemberInfoModel model = new MemberInfoModel();
                        model.ID = entity.ID;
                        model.CardCode = entity.CardCode;
                        model.Name = entity.Name;
                        model.TypeID = entity.TypeID;
                        model.TotalIIntegral = entity.TotalIIntegral;
                        model.Integral = entity.Integral;
                        model.Balance = entity.Balance;
                        model.BarCode = entity.BarCode;
                        model.Mobile = entity.Mobile;
                        model.Birthday = entity.Birthday;
                        model.Email = entity.Email;
                        model.Sex = entity.Sex;
                        model.Credentials = entity.Credentials;
                        model.Duty = entity.Duty;
                        model.Company = entity.Company;
                        model.Telephone = entity.Telephone;
                        model.Address = entity.Address;
                        model.CreateTime = entity.CreateTime;
                        model.UpdateTime = entity.UpdateTime;
                        model.Status = entity.Status;
                        return model;
		}
		
		private EMemberInfo ConvertModelToEntity(MemberInfoModel model)
		{
			if (model == null)
            {
                return null;
            }
			EMemberInfo entity = new EMemberInfo();
                        entity.ID = model.ID;
                        entity.CardCode = model.CardCode;
                        entity.Name = model.Name;
                        entity.TypeID = model.TypeID;
                        entity.TotalIIntegral = model.TotalIIntegral;
                        entity.Integral = model.Integral;
                        entity.Balance = model.Balance;
                        entity.BarCode = model.BarCode;
                        entity.Mobile = model.Mobile;
                        entity.Birthday = model.Birthday;
                        entity.Email = model.Email;
                        entity.Sex = model.Sex;
                        entity.Credentials = model.Credentials;
                        entity.Duty = model.Duty;
                        entity.Company = model.Company;
                        entity.Telephone = model.Telephone;
                        entity.Address = model.Address;
                        entity.CreateTime = model.CreateTime;
                        entity.UpdateTime = model.UpdateTime;
                        entity.Status = model.Status;
                        return entity;
		}
		
		
		
		#endregion
    }
}